package com.zxk.version4.provider;

import java.util.HashMap;
import java.util.Map;

/**
 * @author： 朱小康
 * @create： 2024/5/29 18:05
 */
public class ServiceProvider {

    private Map<String, Object> interfaceProvider = new HashMap<>();


    public void provideServiceInterface(Object service){
        Class<?>[] interfaces = service.getClass().getInterfaces();

        for (Class<?> anInterface : interfaces) {
            interfaceProvider.put(anInterface.getName(),service);
        }
    }

    public Object getService(String interfaceName){
        return interfaceProvider.get(interfaceName);
    }
}
